package logic

import (
	"context"
	"doctor/doctorrpc/models/mysql"
	"gorm.io/gorm"

	"doctor/doctorrpc/doctorrpc"
	"doctor/doctorrpc/internal/svc"

	"github.com/zeromicro/go-zero/core/logx"
)

type ShowLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewShowLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ShowLogic {
	return &ShowLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// 详情
func (l *ShowLogic) Show(in *doctorrpc.ShowRequest) (*doctorrpc.ShowResponse, error) {
	// todo: add your logic here and delete this line
	doctor := mysql.Doctor{
		Model: gorm.Model{ID: uint(in.Id)},
	}
	mysql.DB.Where("id=?", in.Id).Find(&doctor)
	return &doctorrpc.ShowResponse{
		Id:      int64(doctor.ID),
		Name:    doctor.Name,
		Sex:     doctor.Sex,
		Age:     doctor.Age,
		Address: doctor.Address,
	}, nil
}
